<?php
// +----------------------------------------------------------------------
// | 前台公共Action控制器父类
// +----------------------------------------------------------------------
// | @link ( http://www.yurnero.net )
// +----------------------------------------------------------------------
// | @copyright
// +----------------------------------------------------------------------
// | @licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | @author Haijun Wu <nicholasinlove@126.com>
// +----------------------------------------------------------------------
// | $Id: BaseAction.class.php 111 2011-05-09 10:06:46Z nicholasinlove1986@gmail.com $
// +----------------------------------------------------------------------


class BaseAction extends Action {

	//初始化接口
	public function _initialize() {
		
		/* 对用户传入的变量进行去除转义操作。*/
		all_stripslashes();
			
		/* 载入系统参数 */
		global $_CFG; 
		$_CFG = get_config();	
		$this->assign('_CFG',$_CFG);
		
		/* 评论表情 */
		smilies_init();
		
		/* 创建静态缓存文件 */
		import("@.ORG.StaticCaches");
		$cache = new StaticCaches();
		$cache->cacheInit();
		//create_static_caches();
		
		header('Expires: Fri, 14 Mar 1980 20:53:00 GMT');
		header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
		header('Cache-Control: no-cache, must-revalidate');
		header('Pragma: no-cache');
		
		/* 判断是否支持gzip模式 */
		if (gzip_enabled()) {
			ob_start('ob_gzhandler');
		} else {
			ob_start();
		}
		$s = A('Public');
		$s->sidebar();
		$s->header();	
	}
	
	//空操作
	public function _empty() {
		$this->error('Error 404 - Not Found');
	}
	
	//验证码
	public function verify() {
		$type	 =	 isset($_GET['type'])?$_GET['type']:'gif';
		import("@.ORG.Image");
		Image::buildImageVerify(4,3,$type);
	}
	
	//检查用户是否登录
	protected function checkUser() {
		if (!isset($_SESSION[C('USER_AUTH_KEY')])) {
			return true;
		}else{
			return false;
		}
	}
	
}

?>